/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package dao;

import org.hibernate.Session;
import org.hibernate.Transaction;
import logica.Mercadoria;
import util.HibernateUtil;

/**
 *
 * @author AlisonPC
 */
public class MercadoriaDAO {
    private Session sessao;
    private Transaction transacao;

    public void salvar(Mercadoria mercadoria) {
        sessao = HibernateUtil.getSessionFactory().openSession();
        transacao = sessao.beginTransaction();
        sessao.save(mercadoria);
        transacao.commit();
        sessao.close();
    }

    public void remover(Mercadoria mercadoria) {
        sessao = HibernateUtil.getSessionFactory().openSession();
        transacao = sessao.beginTransaction();
        sessao.delete(mercadoria);
        transacao.commit();
        sessao.close();
    }
   
    }

